<extend name="./Public/main" />
<block name="main">
<div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <a href="javascript:;" onclick="addShow(0)"><h5><i class="glyphicon glyphicon-plus" aria-hidden="true"></i>添加轮播</h5></a>
                    </div>
                    <div class="ibox-content">
                        <div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                    <tr>

                                        <th></th>
                                        <th>图片</th>
                                        <th>标题</th>
                                        <th>地址</th>
                                        <th>排序</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                   <volist name="list" id="vo">
                                    <tr>
                                        <td>
                                            <div class="icheckbox_square-green checked" style="position: relative;"><input type="checkbox" checked="" class="i-checks" name="input[]" style="position: absolute; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;"></ins></div>
                                        </td>
                                        <td><img src="{$vo.pic}" width="150px" height="80px" alt=""></td>
                                        <td>{$vo['title']}</td>
                                        <td>{$vo['url']}</td>
                                        <td>{$vo['sort']}</td>
                                        <td>
                                            <a href="javascript:;" onclick="editAlert({$vo['banner_id']})" title="修改" style="margin-right:10px"><i class="glyphicon glyphicon-edit"></i></a>
                                            <a href="{:U('Banner/del',array('banner_id'=>$vo['banner_id']))}"   title="删除"><i class="glyphicon glyphicon-trash"></i></a>
                                        </td>
                                    </tr>
                                    </volist>
                                </tbody>
                            </table>
                            <div class="page1">
                            {$show}
                            </div>
                        </div>

                    </div>
                </div>
            </div>

        </div>
        <!-- 添加弹出框开始 -->
        <div id="AddAlert" style="display:none;position:absolute;left:0px;top:0px;z-index:9999;background:rgba(198,198,198,0.5);width:100%;height:100%">
          <div class="col-sm-6" style="margin-left:470px;margin-top:270px">
                  <div class="ibox float-e-margins">
                      <div class="ibox-title">
                          <h5>添加菜单</h5>
                          <div class="ibox-tools">
                              <a class="close-link" onclick="addClose()">
                                  <i class="fa fa-times"></i>
                              </a>
                          </div>
                      </div>
                      <div class="ibox-content">
                          <div class="row">
                              <div class="col-sm-12">
                                  <form role="form" action="{:U('Friends/add')}" method="post" enctype ="multipart/form-data">
                                      <div class="form-group">
                                          <label>标题</label>
                                          <input type="text"  name="title" class="form-control">
                                      </div>
                                      <div class="form-group">
                                          <label>图片</label>
                                          <input type="file"  name="pic" >
                                      </div>
                                      <div class="form-group">
                                          <label>排序</label>
                                          <input type="text"  name="sort" class="form-control">
                                      </div>
                                      <div class="form-group">
                                          <label>地址（可选）</label>
                                          <input type="text"  name="url" class="form-control">
                                      </div>
                                      <div>
                                          <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit" style="margin-right:450px">
                                             <strong>添加</strong>
                                          </button>
                                          
                                      </div>
                                  </form>
                              </div>
                          </div>
                      </div>
                  </div>
              </div>
            </div>
        <!-- 添加弹出框结束 -->
        
        <!-- 修改弹出框开始 -->
        <div id="editAlert" style="display:none;position:absolute;left:0px;top:0px;z-index:9999;background:rgba(198,198,198,0.5);width:100%;height:100%">
          <div class="col-sm-6" style="margin-left:470px;margin-top:270px">
                  <div class="ibox float-e-margins">
                      <div class="ibox-title">
                          <h5>修改菜单</h5>
                          <div class="ibox-tools">
                              <a class="close-link" onclick="editClose()">
                                  <i class="fa fa-times"></i>
                              </a>
                          </div>
                      </div>
                      <div class="ibox-content">
                          <div class="row">
                              <div class="col-sm-12">
                                  <form role="form" action="{:U('Banner/edit')}" method="post" enctype ="multipart/form-data">
                                      <input type="hidden" name="banner_id" >
                                      <div class="form-group">
                                          <label>标题</label>
                                          <input type="text"  name="title" class="form-control">
                                      </div>
                                      
                                      <div class="form-group">
                                          <label>图片</label>
                                          <input type="hidden"  name="pic" >
                                          <input type="file" name="file">
                                      </div>
                                      <div class="form-group">
                                          <img src="" alt="" width="150px" height="80px">
                                      </div>
                                      <div class="form-group">
                                          <label>排序</label>
                                          <input type="text"  name="sort" class="form-control">
                                      </div>
                                      <div class="form-group">
                                          <label>地址（可选）</label>
                                          <input type="text"  name="url" class="form-control">
                                      </div>
                                      <div class="form-group">
                                          <label>是否显示</label>
                                          <input type="radio"  name="status" value="1"  checked>显示
                                          <input type="radio"  name="status" value="2" >不显示
                                      </div>
                                      <div>
                                          <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit" style="margin-right:450px">
                                             <strong>添加</strong>
                                          </button>
                                          
                                      </div>
                                  </form>
                              </div>
                          </div>
                      </div>
                  </div>
              </div>
            </div>
        <!-- 修改弹出框结束 -->
        <script>
            function addShow(pid){
              $("#AddAlert input[name='parent_id']").val(pid);
              $("#AddAlert").css("display","block");
            }
            function addClose(){
              $("#AddAlert").css("display","none");
            }
            function delAlert(id){
              layer.confirm('确认删除', {
                  btn: ['确定','取消'] //按钮
                }, function(){
                  var str = "{:U('Power/delpower',array('id'=>seatId))}";
                  var url = str.replace("seatId",id)
                  location.href = url;
                }, function(){
                  
                });
            }
            function editClose(){
              $("#editAlert").css("display","none");
            }
            function editAlert(id){
              $("#editAlert").css("display","block");
           
              $.ajax({
                url: "{:U('Banner/info')}",
                data:{banner_id:id},
                type:"post",
                dataType:'json',
                success:function(res){
                    $("#editAlert img").attr('src',res.pic);
                    $("#editAlert input[name='banner_id']").val(res.banner_id);
                    $("#editAlert input[name='pic']").val(res.pic);
                    $("#editAlert input[name='sort']").val(res.sort);
                    $("#editAlert input[name='status']").val(res.status);
                    $("#editAlert input[name='url']").val(res.url);
                    $("#editAlert input[name='title']").val(res.title);
                },
              })
            }
        </script>
</block>